/**
 * @author David Young
 */
package csab.tests.visual;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import csab.LevelBase;

/**
 * A test for the LevelBase class.
 * @author David Young
 */
public class LevelBaseTest extends BasicGame{
	private LevelBase base;
	
	/**
	 * The entry point for this test.
	 * @param args Not parsed.
	 * @throws SlickException
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws SlickException, InterruptedException {
		AppGameContainer gc = new AppGameContainer(new LevelBaseTest());
		float aspect = (float)gc.getScreenWidth() / gc.getScreenHeight();
		//Calculate for aspect ratios
		float epsilon = 0.01f;
		if(Math.abs(aspect - (float)16/9) < epsilon)
			gc.setDisplayMode(1280, 720, false);
		else if(Math.abs(aspect - (float)4/3) < epsilon)
			gc.setDisplayMode(800, 600, false);
		else if(Math.abs(aspect - (float)16/10) < epsilon)
			gc.setDisplayMode(1280, 800, false);
		else {
			gc.setDisplayMode(800, 600, false);
		}
		gc.setClearEachFrame(false);
		gc.setUpdateOnlyWhenVisible(true);
		gc.setFullscreen(false);
		Thread.sleep(1000);
		gc.start();
	}

	/**
	 * Constructor for an object of this class.
	 */
	public LevelBaseTest() {
		super("LevelBaseTest");
	}

	/* (non-Javadoc)
	 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
	 */
	@Override
	public void init(GameContainer arg0) throws SlickException {
		base = new LevelBase("resource/maps/TestMap1.tmx");
		base.init(arg0);
	}

	/* (non-Javadoc)
	 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
	 */
	@Override
	public void render(GameContainer arg0, Graphics arg1) throws SlickException {
		base.render(arg0, arg1);
	}
	
	/* (non-Javadoc)
	 * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
	 */
	@Override
	public void update(GameContainer arg0, int arg1) throws SlickException {
		base.update(arg0, arg1);
	}

}
